package com.jd.sunny.java;

/**
 * @Description:test class
 * @author:sunlin
 * @since:2012-11-29 11:01
 * @version:1.0.0
 */
public class TestClass {

    public static void main(String[] args ){
        getClassMethod();
        System.out.println(getClassInstance("com.jd.sunny.java.Employee").getClass().getName());
    }


    /**
     * test three get class object method
     */
    private static void getClassMethod(){
        //first
        Employee employee = new Employee();
        Class class1 =  employee.getClass();

        //second
        try {
            Class class2 = Class.forName("com.jd.sunny.java.Employee");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();  
        }

        //third
        Class class3 = Employee.class;

    }

    /**
     * get class instance
     */
    private static Object getClassInstance(String classStr){
         Object object = null;
        try {
            object =  Class.forName(classStr).newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();  
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return object;
    }

}
